@include('admin.layout.bone_header')

<div class="layui-form layui-form-pane search">
    <div class="layui-form-item">
        <label class="layui-form-label">用户id</label>
        <div class="layui-input-inline">
            <input type="text" id="user_id" autocomplete="off" placeholder="请输入用户信息" class="layui-input">
        </div>
        <button class="layui-btn" data-type="reload">搜索</button>
    </div>
</div>
<div class="layui-btn-container">

</div>

<table class="layui-hide" id="think-table" lay-filter="think-table"></table>


<script id="barDemo" type="text/html">
    @{{#  if(d.status ==0 ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="audit_withwal">审核</a>
    @{{#  } }}
</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.shops.kucun')}}", [
            {field: 'stock_id', title: 'ID', width:80, sort: true,fixed: 'left'}
            ,{field: 'goods_name',title:'商品名称',templet:function (d){
                    if(d['goods'].length < 1){
                        return '暂无'
                    }
                    return  d['goods'][0]['project_name']
                }}
            ,{field: 'nums',title:'数量'}
            ,{field: 'user_id',title:'用户id'}
            ,{field: 'user_id',title:'用户信息',templet:function (d){
                    if(d['user_info'] == null){
                        return '暂无'
                    }
                    return  d['user_info']['nickname']
                }}
            ,{field: 'created_at',title:'创建时间',templet:function (d){
                    return layui.util.toDateString(parseInt(d['created_at'])*1000,'yyyy-MM-dd HH:mm:ss')
                }}
            // ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event == 'audit_withwal'){
                UI.openLayer("{{route('admin.bill.audit')}}?bill_id="+data['bill_id']);
            }
        });
        let $ = layui.$, active = {
            addCategory:function (){
                UI.openLayer("{{route('admin.category.add')}}");
            },
            reload:function (){
                let search_key = $('#user_id');
                //执行重载
                table.reload('think-table', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        'user_id':search_key.val(),
                    }
                });
            }
        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
